package com.ruoyi.yl.rocketmq;

import com.ruoyi.yl.rocketmq.product.MessageProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    @Autowired
    private MessageProducer messageProducer;

    @GetMapping("/send")
    public String sendMessage(@RequestParam String message) {
        messageProducer.sendMessage("test-topic", message);
        return "Message sent: " + message;
    }

    @GetMapping("/send-tag")
    public String sendMessageWithTag(@RequestParam String tag,
                                     @RequestParam String message) {
        messageProducer.sendMessageWithTag("test-topic", tag, message);
        return "Message with tag sent: " + message;
    }

    @GetMapping("/send-transaction")
    public String sendTransactionMessage(@RequestParam String message) {
        messageProducer.sendTransactionMessage("test-topic", message, null);
        return "Transaction message sent: " + message;
    }


    @GetMapping("/send-delay")
    public String sendDelayMessage(@RequestParam String message) {
        messageProducer.sendDelayMessage("test-topic","test-tag", message);
        return "Delay message sent: " + message;
    }
}